package com.seguriapp.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.seguriapp.R;
import com.seguriapp.controllers.ComplaintController;
import com.seguriapp.controllers.EntityController;
import com.seguriapp.controllers.TramitesController;
import com.seguriapp.util.AppPrefences;

public class SplashActivity extends Activity {
	public static int SPLASH_TIME = 1000;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		final AppPrefences msp = new AppPrefences(this);
		if (!msp.isInitialData()) {
			final EntityController eController = new EntityController(this);
			eController.insertInitialEntities();
			final ComplaintController cController = new ComplaintController(
					this);
			cController.insertInitialCategories();
			final TramitesController tController = new TramitesController(this);
			tController.insertInitialTramites();
		}

		new Handler().postDelayed(new Runnable() {
			public void run() {
				showNext();
			}
		}, SPLASH_TIME);

	}

	/**
	 * Load the next activity
	 */
	public void showNext() {
		final Intent activityIntent = new Intent(this, MainActivity.class);
		startActivity(activityIntent);
		finish();
	}

}
